package com.llb666.e.shop.api.controller.center;

import com.llb666.e.shop.api.vo.CenterUsersVo;
import com.llb666.e.shop.domain.service.CenterUserService;
import com.llb666.e.shop.infracore.web.BaseResponse;
import com.llb666.e.shop.infracore.web.DataResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 斌~
 * @version 1.0
 * @date 2021/10/8 4:04 下午
 */
@Tag(name = "center-用户中心", description = "用户中心展示相关Api接口")
@RestController
@RequestMapping("center")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CenterController {

    private final CenterUserService userService;

    @Operation(summary = "获取用户信息", description = "获取用户信息", method = "GET")
    @GetMapping("userInfo")
    public BaseResponse userInfo(@Parameter(name = "userId", description = "用户ID", required = true)
                                 @RequestParam String userId) {
        CenterUsersVo centerUsersVo = CenterUsersVo.Converter.INSTANCE.do2Vo(userService.queryUserInfo(userId));
        return DataResponse.ok(centerUsersVo);
    }

}
